<?php
session_start();
if (empty($_SESSION['username'])) {
    echo '<script type="text/javascript">window.location.href="index.php";</script>';
} else {
    $now = time();
    if ($now > $_SESSION['expire']) {
        session_destroy();
        echo '<script type="text/javascript">var r=confirm("Session expire (30 mins)!"); if(r==true){window.location.href="index.php";}else{window.location.href="index.php";}</script>';
    } else {
        
    }
}
?>
<!DOCTYPE html>
<html lang="en">

    <head>

        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="">

        <title>SwissMooh - Admin Page</title>

        <!-- Bootstrap Core CSS -->
        <link href="assets/css/bootstrap.min.css" rel="stylesheet">

        <!-- Custom CSS -->
        <link href="assets/css/sb-admin.css" rel="stylesheet">

        <!-- Morris Charts CSS -->
        <link href="assets/css/plugins/morris.css" rel="stylesheet">
        <link href="assets/css/plugins/summernote/summernote.css" rel="stylesheet">
        <!-- Custom Fonts -->
        <link href="assets/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
        <link href="assets/css/jquery-ui.min.css" rel="stylesheet" type="text/css">

        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
        <style>            
            label, input { display:block; }
            input.text { margin-bottom:12px; width:95%; padding: .4em; }
            fieldset { padding:0; border:0; margin-top:25px; }
            h1 { font-size: 1.2em; margin: .6em 0; }
            div#users-contain { width: 350px; margin: 20px 0; }
            div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
            div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
            .ui-dialog .ui-state-error { padding: .3em; }
            .validateTips { border: 1px solid transparent; padding: 0.3em; }
            .hide_add_menu {visibility: hidden;'}
            </style>
        </head>

        <body>

            <div id="wrapper">

                <!-- Navigation -->
                <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
                    <!-- Brand and toggle get grouped for better mobile display -->
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="navbar-brand" href="welcome_page.php">SwissMooh Admin</a>
                    </div>
                    <!-- Top Menu Items -->
                    <ul class="nav navbar-right top-nav">                                        
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> <?= $_SESSION['username'] ?><b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                <li>
                                    <a href="change_password.php">Change Password</a>
                                </li>
                                <li class="divider"></li>
                                <li>
                                    <a href="#" id="logout_click"><i class="fa fa-fw fa-power-off"></i> Log Out</a>
                                </li>
                            </ul>
                        </li>
                    </ul>
                    <!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
                    <div class="collapse navbar-collapse navbar-ex1-collapse">
                        <ul class="nav navbar-nav side-nav">
                            <li>
                                <a href="menu_main_page.php"><i class="fa fa-fw fa-bar-chart-o"></i> Manage Menu List</a>
                            </li>
                            <li class="active">
                                <a href="manage_carousel_page.php"><i class="fa fa-fw fa-edit"></i> Manage Carousel Content</a>
                            </li>
                            <li>
                                <a href="contact_main_page.php"><i class="fa fa-fw fa-edit"></i> Manage Contact Content</a>
                            </li>
                        </ul>
                    </div>
                    <!-- /.navbar-collapse -->
                </nav>

                <div id="page-wrapper">

                    <div class="container-fluid">

                        <!-- Page Heading -->
                        <div class="row">
                            <div class="col-lg-12">
                                <h1 class="page-header">
                                    Contact <small>Manage Carousel Page</small>
                                </h1>
                                <ol class="breadcrumb">
                                    <li class="active">
                                        <i class="fa fa-dashboard"></i> Manage Carousel
                                    </li>
                                </ol>
                            </div>
                        </div>
                        <div class="row">

                            <div class="col-lg-12" id="content_manage">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <h3 class="panel-title">Carousel Page Top Management</h3>
                                    </div>
                                    <div class="panel-body">
                                        <div class="col-lg-4" id="content_manage">
                                            <div class="panel panel-default">
                                                <div class="panel-heading">
                                                    <div class="pull-right">
                                                        <input type="button" class="btn btn-xs btn-primary" id="add_left_crousel" value="Add"/>
                                                    </div>
                                                    <h3 class="panel-title">Left Carousel</h3>
                                                </div>
                                                <div class="panel-body">
                                                    <div class="list-group" id="left_carousel">

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-4" id="content_manage">
                                            <div class="panel panel-default">
                                                <div class="panel-heading">
                                                    <div class="pull-right">
                                                        <input type="button" class="btn btn-xs btn-primary" id="add_center_crousel" value="Add"/>
                                                    </div>
                                                    <h3 class="panel-title">Center Carousel</h3>
                                                </div>
                                                <div class="panel-body">
                                                    <div class="list-group" id="center_carousel">

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-lg-4" id="content_manage">
                                            <div class="panel panel-default">
                                                <div class="panel-heading">
                                                    <div class="pull-right">
                                                        <input type="button" class="btn btn-xs btn-primary" id="add_right_crousel" value="Add"/>
                                                    </div>
                                                    <h3 class="panel-title">Right Carousel</h3>
                                                </div>
                                                <div class="panel-body">
                                                    <div class="list-group" id="right_carousel">

                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-12" id="content_manage">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <div class="pull-right">
                                            <input type="button" class="btn btn-xs btn-primary" id="add_bottom_crousel" value="Add"/>
                                        </div>
                                        <h3 class="panel-title">Carousel Page Bottom Management</h3>
                                    </div>
                                    <div class="panel-body">
                                        <div class="list-group" id="buttom_carousel">

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- /.row -->

                        <div class="row" style="height: 400px;"></div>
                    </div>
                    <!-- /.container-fluid -->

                </div>
                <!-- /#page-wrapper -->

            </div>
            <!-- /#wrapper -->

            <script src="assets/js/jquery.js"></script>
            <script src="assets/js/jquery-ui.min.js"></script>
            <!-- Bootstrap Core JavaScript -->
            <script src="assets/js/bootstrap.min.js"></script>
            <script type="text/javascript" src="assets/js/plugins/summernote/summernote.js"></script>
            <script src="assets/js/jquery.blockUI.js"></script>
            <script src="assets/js/SwissMoohScript.js"></script>
            <script type="text/javascript">
                $(document).ready(function () {
                    updateSessionTimeOutCallBack();
                    var leftDialog = $("#dialog-add-leftcarousel").dialog({
                        autoOpen: false,
                        height: 210,
                        width: 350,
                        modal: true
                    });
                    var centerDialog = $("#dialog-add-Centertcarousel").dialog({
                        autoOpen: false,
                        height: 260,
                        width: 350,
                        modal: true
                    });
                    var rightDialog = $("#dialog-add-Rightcarousel").dialog({
                        autoOpen: false,
                        height: 210,
                        width: 350,
                        modal: true
                    });
                    var buttomDialog = $("#dialog-add-ButtomCarousel").dialog({
                        autoOpen: false,
                        height: 280,
                        width: 350,
                        modal: true
                    });
                    $.ajax({
                        url: "model/com.swiss.mooh.controller/GetAllCarousel.php",
                        type: 'POST',
                        data: {'type': 'BUTTOM'},
                        success: function (data, textStatus, jqXHR) {
                            $("#buttom_carousel").html(data);
                        }
                    });
                    $.ajax({
                        url: "model/com.swiss.mooh.controller/GetAllCarousel.php",
                        type: 'POST',
                        data: {'type': 'LEFT'},
                        success: function (data, textStatus, jqXHR) {
                            $("#left_carousel").html(data);
                        }
                    });
                    $.ajax({
                        url: "model/com.swiss.mooh.controller/GetAllCarousel.php",
                        type: 'POST',
                        data: {'type': 'CENTER'},
                        success: function (data, textStatus, jqXHR) {
                            $("#center_carousel").html(data);
                        }
                    });
                    $.ajax({
                        url: "model/com.swiss.mooh.controller/GetAllCarousel.php",
                        type: 'POST',
                        data: {'type': 'RIGHT'},
                        success: function (data, textStatus, jqXHR) {
                            $("#right_carousel").html(data);
                        }
                    });

                    $("#add_left_crousel").click(function () {
                        updateSessionTimeOutCallBack();
                        leftDialog.dialog("open");
                    });
                    $("#add_center_crousel").click(function () {
                        updateSessionTimeOutCallBack();
                        centerDialog.dialog("open");
                    });
                    $("#add_right_crousel").click(function () {
                        updateSessionTimeOutCallBack();
                        rightDialog.dialog("open");
                    });
                    $("#add_bottom_crousel").click(function () {
                        updateSessionTimeOutCallBack();
                        buttomDialog.dialog("open");
                    });
                });
                function deleteCarousel(caID) {
                    updateSessionTimeOutCallBack();
                    $.ajax({
                        url: "model/com.swiss.mooh.controller/DeleteCarouselByID.php",
                        type: 'POST',
                        data: {'caID': caID},
                        success: function (data, textStatus, jqXHR) {
                            if (data == 200) {
                                window.location = "manage_carousel_page.php";
                            } else {
                                alert(data);
                            }
                        }
                    });
                }
            </script>
        </body>
        <div id="dialog-add-leftcarousel" title="Create left carousel">
            <form name="leftCaForm" method="post" action="model/com.swiss.mooh.controller/uploadLeftCA.php" enctype="multipart/form-data">
                <label for="name">Carousel Link</label>
                <input type="text" name="leftCaLink" id="leftCaLink" class="text ui-widget-content ui-corner-all">          
                <input type="file" name="leftCaFileName" id="leftCaFileName" class="text ui-widget-content ui-corner-all">
                <input type="submit" style="position:absolute;" value="Create"/>
            </form>
        </div>
        <div id="dialog-add-Centertcarousel" title="Create Center carousel">
            <form name="centerCaForm" method="post" action="model/com.swiss.mooh.controller/uploadCenterCA.php" enctype="multipart/form-data">
                <label for="name">Carousel Link</label>
                <input type="text" name="centerCaLink" id="centerCaLink" class="text ui-widget-content ui-corner-all">
                <label for="name">Carousel Text</label>
                <input type="text" name="centerCaFileName" id="centerCaFileName" class="text ui-widget-content ui-corner-all">
                <input type="submit" style="position:absolute;" value="Create"/>
            </form>
        </div>
        <div id="dialog-add-Rightcarousel" title="Create Right carousel">
            <form name="centerCaForm" method="post" action="model/com.swiss.mooh.controller/uploadRightCA.php" enctype="multipart/form-data">
                <label for="name">Carousel Link</label>
                <input type="text" name="rightCaLink" id="rightCaLink" class="text ui-widget-content ui-corner-all">
                <input type="file" name="rightCaFileName" id="rightCaFileName" class="text ui-widget-content ui-corner-all">
                <input type="submit" style="position:absolute;" value="Create"/>
            </form>
        </div>
        <div id="dialog-add-ButtomCarousel" title="Create Buttom carousel">
            <form name="centerCaForm" method="post" action="model/com.swiss.mooh.controller/uploadButtomCA.php" enctype="multipart/form-data">
                <label for="buttomCaLink">Carousel Link</label>
                <input type="text" name="buttomCaLink" id="buttomCaLink" class="text ui-widget-content ui-corner-all">
                <label for="buttomCaName">Carousel Name</label>
                <input type="text" name="buttomCaName" id="buttomCaName" class="text ui-widget-content ui-corner-all">
                <input type="file" name="buttomCaFileName" id="buttomCaFileName" class="text ui-widget-content ui-corner-all">
                <input type="submit" style="position:absolute;" value="Create"/>
            </form>
        </div>
    </html>
